package Text26;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int x = in.nextInt();
        System.out.println((x + m * qmi(10,k,n) % n) % n);
    }

    private static long qmi(long x, int k, int q) {
        long ret = 1 % q;
        while (k > 0) {
            if ((k & 1) == 1) {
                ret = ret * x % q;
            }
            x = x * x % q;
            k >>= 1;
        }
        return ret;
    }
}


